package interview_questions;

import java.util.Scanner;

public class Main1_7 {
	public static void clear(int[][] matrix) {
		int M = matrix.length;
		int N = matrix[0].length;
		boolean[] row = new boolean[M];
		boolean[] column = new boolean[N];
		for (int i = 0; i < M; i++)
			for (int j = 0; j < N; j++)
				if (matrix[i][j] == 0) {
					row[i] = true;
					column[j] = true;
				}
		for (int i = 0; i < M; i++)
			for (int j = 0; j < N; j++)
				if (row[i] || column[j])
					matrix[i][j] = 0;
	}

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int M = in.nextInt();
		int N = in.nextInt();
		int[][] matrix = new int[M][N];
		for (int i = 0; i < M; i++)
			for (int j = 0; j < N; j++)
				matrix[i][j] = in.nextInt();
		clear(matrix);
		for (int i = 0; i < M; i++) {
			for (int j = 0; j < N; j++)
				System.out.print(matrix[i][j] + " ");
			System.out.println();
		}
		in.close();
	}

}
